home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS13.ADF
/
FutureSound
/
loadsound.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-08-05
|
2KB
|
76 lines
/* LoadSound.c */
/* This routine will load a soundfile from disk, */
/* provided that the file was saved in either */
/* IFF or FutureSound format, and resides in the */
/* current default directory. */
/* Usage : LoadFile(filename,buffer) */
/* filename is a pointer to a string */
/* buffer is a pointer (char *) to an allocated memory area */
/* return value : record rate (UWORD) */
/* converted to use AmigaDOS I/O calls, John Foust, 6/22/86 */
#include "exec/types.h" /* Amiga typedefs */
#include "lattice/stdio.h" /* Lattice I/O defs */
#include "SoundErrors.h" /* FutureSound aux routine error codes */
#include "libraries/dosextens.h"
extern struct FileHandle *Open();
extern UWORD ReadIFF(); /* IFF file reader (returns rec rate) */
extern ULONG SizeIFF(); /* returns size of IFF data */
UWORD LoadSound(filename,buffer) /* Read SoundFile */
char *filename,*buffer;
{
/* FILE *fd; */
struct FileHandle *fp; /* File Pointer */
ULONG len; /* Data Length */
UWORD rec_rate; /* Record Rate (kHz) */
/* Is it an IFF File? */
if((len=SizeIFF(filename)) != 0)
{
/* Yes, then read in IFF format */
return(ReadIFF(filename,buffer));
}
else
{
/* No, then read in FutureSound format */
/* Open file for reading */
if((fp = Open(filename,MODE_OLDFILE)) == 0)
{
return(Error(OPEN_ERROR,filename));
}
/* Read length of data */
if(Read(fp,&len,sizeof(len))==0)
{
return(Error(READ_ERROR,filename));
}
/* Read record rate */
if(Read(fp,&rec_rate,sizeof(rec_rate)) == 0)
{
return(Error(READ_ERROR,filename));
}
/* Read data into buffer */
if(Read(fp,buffer,len) == 0)
{
return(Error(READ_ERROR,filename));
}
/* Close file */
Close(fp);
/* Return record rate if file was successfully read */
return(rec_rate);
}
}